package org.jit.sose.service.impl;

import org.jit.sose.entity.User;
import org.jit.sose.service.MemberService;
import org.jit.sose.util.ResponseUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 会员接口实现类
 * 
 * @author: wangyue
 * @date: 2020-03-24 00:35:42
 */
@Slf4j
@Api(tags = "MemberService", description = "会员服务")
@RestController
public class MemberServiceImpl implements MemberService {

	@GetMapping("/")
	public String serviceInfo() {
		return "这是member服务";
	}

	@Override
	@GetMapping("hello")
	public String hello() {
		log.info("hello");
//		try {
//			// 6秒延迟
//			Thread.sleep(6000);
//			log.info("6秒延迟");
//		} catch (Exception e) {
//			// TODO: handle exception
//		}
		return ResponseUtil.success("Hello,SpringCloud");
	}

	@Override
    @ApiOperation(value = "根据用户名获取用户信息")
	@ApiImplicitParam(name = "name", value = "用户名", paramType = "query", required = true, dataTypeClass = String.class)
	@GetMapping("/getUserByName")
	public User getUserByName(@RequestParam("name") String name) {
		log.info(name);
		try {
			// 6秒延迟
			Thread.sleep(2000);
			log.info("6秒延迟");
		} catch (Exception e) {
			// TODO: handle exception
		}
		return new User(name);
	}
}
